package com.aat.dxfy.jsecurity;

import java.security.*;

import javax.security.auth.*;
import javax.security.auth.login.*;

public class Test01 {

	public static void main(String[] args) {
		System.setSecurityManager(new SecurityManager());
		try{
			LoginContext context=new LoginContext("login 1");
			context.login();
			System.out.println("Auth success");
			
			Subject sub=context.getSubject();
			System.out.println("sub:"+sub);
			
			PrivilegedAction<String> action=new SysPropAction("user.home");
			
			String result=Subject.doAsPrivileged(sub, action, null);
			System.out.println(result);
			context.logout();
		}catch(Exception e){
			
		}
	}

}
